package dynamic.domain;

import lombok.Data;

import java.util.Objects;

/**
 * @author 罗俊华
 * @date 2021/7/20 - 2:44 下午
 */
@Data
public class PointFlag {

    private int x;

    private int y;

    public static final int WHITE = 0;

    public static final int GREY = 1;

    private int cost;

    private int weight;

    private int color = WHITE;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        PointFlag pointFlag = (PointFlag) o;
        return x == pointFlag.x &&
                y == pointFlag.y;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }

    @Override
    public String toString() {
        return "PointFlag{" +
                "x=" + x +
                ", y=" + y +
                ", cost=" + cost +
                ", weight=" + weight +
                ", color=" + color +
                '}';
    }

    public PointFlag(int x, int y, int weight) {
        this.x = x;
        this.y = y;
        this.weight = weight;
    }

    public boolean isVisited() {
        return this.color == GREY;
    }

    public void setVisited() {
        this.color = GREY;
    }

    public void setUnvisited() {
        this.color = WHITE;
    }
}
